#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <unordered_map>
using namespace std;

int n;
#define MASK(n) ((1<<(n+1))-2) //如 6 得到的是1000 0000 -> 111 1110,零位上的1不用
unordered_map<int, int> ind;

int tot = 3;
int arr[20];
void out()
{
	for (int i = 1; i <= n; i++) {
		if (i > 1) cout << " ";
		printf("%d", arr[i]);
	}
	printf("\n");
	tot--;
	return;
}

int dfs(int i, int t1, int t2, int t3) 
{
	if (i > n) {
		if(tot) out();
		return 1;
	}
	int ans = 0;
	for (int t = t1; t; t -= (-t & t)) {
		int j = ind[-t & t];
		if ((t2 & (1 << (i + j - 1))) && (t3 & (1 << (i - j + n)))) //正斜线和反斜线
		{
			arr[i] = j;
			ans += dfs(i + 1, t1^(1 << j), t2^(1 << (i + j - 1)), t3^(1 << (i - j + n))); //把t1中的j标记为0,然后向左移动一位
		}
	}
	return ans;
}


int main()
{
	scanf("%d", &n);
	for (int i = 0; i < 2 * n; i++) ind[1 << i] = i;
	int ans = dfs(1, MASK(n), MASK(2 * n - 1), MASK(2 * n - 1)); //列，正斜边，反斜边
	cout << ans << "\n";
	return 0;
}